import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) throws Exception {

        Integer[] array = Integers.random(5, 10, 99);
        System.out.println(Arrays.toString(array));

        BinaryHeap<Integer> binaryHeap;

        {
            binaryHeap = new BinaryHeap<>(new Comparator<>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o1 - o2;
                }
            });

            for (Integer n : array) {
                binaryHeap.add(n);
            }

            Asserts.test(binaryHeap.isHeap());

            while (binaryHeap.isEmpty()) {
                System.out.println(binaryHeap.remove());
            }
        }

        {
            binaryHeap = new BinaryHeap<>(array, new Comparator<>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return o2 - o1;
                }
            });

            Asserts.test(binaryHeap.isHeap());

            while (binaryHeap.isEmpty()) {
                System.out.println(binaryHeap.remove());
            }
        }
    }
}
